package com.pjchat.pjchatclient.sender;

import java.io.BufferedWriter;
import java.io.IOException;

import javax.swing.JOptionPane;

import com.ita.im.model.Unit;
import com.pjchat.pjchatclient.util.JsonUtil;

public class ForwardSender {
	public static boolean send(BufferedWriter bw, Unit unit) {
		try {
			bw.write(JsonUtil.unitToJsonObject(unit) + "\n");
			bw.flush();
		} catch (IOException e) {
			int a = JOptionPane.NO_OPTION;
			while (a != 0) {
				a = JOptionPane.showConfirmDialog(null,
						"Can't connect to server,please try later", "温馨提示",
						JOptionPane.YES_NO_OPTION);
				switch (a) {
				case JOptionPane.YES_OPTION:
					System.exit(0);
					break;
				default:
					break;
				}
			}
			e.printStackTrace();
		}

		return true;
	}
}
